package cn.com.firmlink.rms.component.navigation
{
	import mx.collections.ArrayCollection;
	
	[Bindable]
	public class ActionQueue
	{
		public function ActionQueue()
		{
			this.list = new ArrayCollection();
		}
		
		public var list:ArrayCollection;
		
		public function put(viewMoudle: ViewMoudle):void{
			this.list.addItem(viewMoudle);
			this.list.refresh();
		}
		
		public function remove(moudleID:String):void{
		   var index:int = find(moudleID);
		   if( index >= 0){
		    	var n:int = list.length - index - 1;
		    	for(var i:int=0; i<n; i++){
		     		list.removeItemAt(index+1);
		    	}
		   }
		}
		
		public function removeAll():void{
			list.removeAll();
			list.refresh();
		}
		
		
		private function find(moudleID:String):int{
			for(var i:int = 0; i < list.length; i++){
				var viewMoudle: ViewMoudle = list.getItemAt(i) as ViewMoudle;
				if(viewMoudle.moudleID == moudleID){
					return i;
				}
			}
			return -1;
		}
	}
}